package com.cloudsigns.factorymanager2.produce.bean;

import android.text.TextUtils;

import com.cloudsigns.factorymanager2.cusenum.CommonEnum;
import com.cloudsigns.factorymanager2.produce.utils.ParseJson;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;

public class ShapeTypeBean implements Serializable {
    private int border;//可选	---	圆的留边, 圆形时必须
    private int borderBottom;//可选	---	留边尺寸：下, 方形时必须
    private int borderLeft;//可选	---	留边尺寸：左, 方形时必须
    private int borderRight;//可选	---	留边尺寸：右, 方形时必须
    private int borderTop;//可选	---	留边尺寸：上, 方形时必须
    private String desc;//可选	---	异性的介绍, 异性时必须
    private int diameter;//可选	---	圆的直径, 圆形时必须
    private int height;//可选	---	方形的高, 方形时必须
    private int thick;//可选	---	厚度
    private CommonEnum.ProductShapeType type;//必须	必须为以下可用值之一: [ "ROUND", "RECTANGLE", "SPECIALSHAPE" ]产品规格, 有圆形，矩形，异性
    private int width;//可选	---	方形的宽, 方形时必须

    public int getBorder() {
        return border;
    }

    public void setBorder(int border) {
        this.border = border;
    }

    public int getBorderBottom() {
        return borderBottom;
    }

    public String getBorderBottomStr() {
        if (borderBottom == 0) {
            return "";
        }
        return String.valueOf(borderBottom);
    }

    public void setBorderBottom(int borderBottom) {
        this.borderBottom = borderBottom;
    }

    public int getBorderLeft() {
        return borderLeft;
    }

    public String getBorderLeftStr() {
        if (borderLeft == 0) {
            return "";
        }
        return String.valueOf(borderLeft);
    }

    public void setBorderLeft(int borderLeft) {
        this.borderLeft = borderLeft;
    }

    public int getBorderRight() {
        return borderRight;
    }

    public String getBorderRightStr() {
        if (borderRight == 0) {
            return "";
        }
        return String.valueOf(borderRight);
    }

    public void setBorderRight(int borderRight) {
        this.borderRight = borderRight;
    }

    public int getBorderTop() {
        return borderTop;
    }

    public String getBorderTopStr() {
        if (borderTop == 0) {
            return "";
        }
        return String.valueOf(borderTop);
    }

    public void setBorderTop(int borderTop) {
        this.borderTop = borderTop;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public int getDiameter() {
        return diameter;
    }

    public String getDiameterStr() {
        if (diameter == 0) {
            return "";
        }
        return String.valueOf(diameter);
    }

    public void setDiameter(int diameter) {
        this.diameter = diameter;
    }

    public int getHeight() {
        return height;
    }

    public String getHeightStr() {
        if (height == 0) {
            return "";
        }
        return String.valueOf(height);
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public int getThick() {
        return thick;
    }

    public String getThickStr() {
        if (thick == 0) {
            return "";
        }
        return String.valueOf(thick);
    }

    public void setThick(int thick) {
        this.thick = thick;
    }

    public CommonEnum.ProductShapeType getType() {
        return type;
    }

    public void setType(CommonEnum.ProductShapeType type) {
        this.type = type;
    }

    public int getWidth() {
        return width;
    }

    public String getWidthStr() {
        if (width == 0) {
            return "";
        }
        return String.valueOf(width);
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public void parseObject(JSONObject shapeTypeJsonObj) throws JSONException {
        setBorder(shapeTypeJsonObj.getInt("border"));
        setBorderBottom(shapeTypeJsonObj.getInt("borderBottom"));
        setBorderLeft(shapeTypeJsonObj.getInt("borderLeft"));
        setBorderRight(shapeTypeJsonObj.getInt("borderRight"));
        setBorderTop(shapeTypeJsonObj.getInt("borderTop"));
        setDesc(shapeTypeJsonObj.getString("desc"));
        setDiameter(shapeTypeJsonObj.getInt("diameter"));
        setHeight(shapeTypeJsonObj.getInt("height"));
        setThick(shapeTypeJsonObj.getInt("thick"));
        CommonEnum.ProductShapeType shapeType=ParseJson.parseProductShapeType(shapeTypeJsonObj,"type");
        setType(shapeType);
        setWidth(shapeTypeJsonObj.getInt("width"));
    }
}
